package org.leviatan.dataharbour.gui.swingcomponents;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import org.leviatan.definator.client.DefinatorServiceProxy;
import org.leviatan.definator.gui.RuntimeContext;
import org.leviatan.definator.gui.swingcomponents.LeftMainPanel;
import org.leviatan.definator.gui.swingcomponents.RightEditViewPane;

public class DefinatorTab extends JPanel {

	
	private JSplitPane jSplitPane;
	
	private JScrollPane jScrollPaneLeft;
	
	private JScrollPane jScrollPaneRight;
	
	
	
	private static final long serialVersionUID = 1L;

	/**
	 * This is the default constructor
	 */
	public DefinatorTab() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		
		DefinatorServiceProxy service = DefinatorServiceProxy.buildLocalProxy();
		service.loadConfiguration("E:/dev/shared_dev/definator-resources/conf/definator.conf");
		
		RuntimeContext.definatorService = service;
		
		service.loadRegister();
		
		
		this.setSize(300, 200);
		this.setLayout(new BorderLayout());
		this.add(getJSplitPane());
		
		
		
		
	}
	
	private JSplitPane getJSplitPane() {
		if (jSplitPane == null) {
			jSplitPane = new JSplitPane();
			jSplitPane.setLeftComponent(getLeftJScrollPane());
			jSplitPane.setRightComponent(getRightJScrollPane());
		}
		return jSplitPane;
	}
	
	private JScrollPane getLeftJScrollPane() {
		if (jScrollPaneLeft == null) {
			jScrollPaneLeft = new JScrollPane(new LeftMainPanel());
			jScrollPaneLeft.setPreferredSize(new Dimension(300, 500));
		}
		return jScrollPaneLeft;
	}
	
	
	private JScrollPane getRightJScrollPane() {
		if (jScrollPaneRight == null) {
			jScrollPaneRight = new JScrollPane(new RightEditViewPane());
			//jScrollPaneRight.add(new RightEditViewPane());
			//jScrollPaneRight.add(getJTable());
			//jScrollPaneRight.setPreferredSize(new Dimension(300, 0));
		}
		return jScrollPaneRight;
	}

}
